using Microsoft.EntityFrameworkCore;

using Qgm.Three.Back.Entities;

using WL.Think.Abp.EntityFrameworkCore;
using WL.Think.Sample.Books;

namespace WL.Think.Sample;

public class SampleDbContext : AppIdentityDbContext<SampleDbContext>
{
    public DbSet<BookEntity> Books { get; set; }

    public SampleDbContext(DbContextOptions<SampleDbContext> options) : base(options)
    {
    }

    protected override void ConfigureMapping(ModelBuilder builder)
    {
        ThinkDbContextTableOptions.Configure("App");
        builder.Mapping<BookEntity>(b =>
        {
            b.Property(x => x.Name).IsRequired().HasMaxLength(128);
        });

        builder.Mapping<DeviceCategoryEntity>(b =>
        {
            b.Property(x => x.IsHost).HasComment("是否主机分类");
        });
    }

    protected override void ConfigureOptionBuilder(DbContextOptionsBuilder optionsBuilder)
    {
        base.ConfigureOptionBuilder(optionsBuilder);
        optionsBuilder.EnableSensitiveDataLogging().EnableDetailedErrors();
    }
}
